package cn.bigway.app.weavingdesigner.util;

import java.util.HashMap;

abstract public class WdBaseFactory<T, E extends Enum<E>> {

	private final HashMap<String, T> items = new HashMap<String, T>();

	abstract protected T create(E type);

	public final T get(E type) {
		T item = this.items.get(type.name());
		if (null == item) {
			item = create(type);
			this.items.put(type.name(), item);
		}
		return item;
	}
}
